package com.example.flight.common;

import io.jsonwebtoken.JwtException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler(JwtException.class)
    public Result doJwtException(JwtException ex){
        ex.printStackTrace();
        return Result.error().code(401).message("登录状态错误");
    }
    @ExceptionHandler(BuyException.class)
    public Result doBuyException(BuyException ex){

        ex.printStackTrace();
        return Result.error().message("购买失败");
    }

    @ExceptionHandler(Exception.class)
    public Result doException(Exception ex){

        ex.printStackTrace();
        return Result.error();
    }
}